package com.bistu.sim.xwy.news.Http;

import com.bistu.sim.xwy.news.domain.BusGood;
import com.bistu.sim.xwy.news.domain.BusInfo;
import com.bistu.sim.xwy.news.domain.BusUser;
import com.bistu.sim.xwy.news.domain.NewsCom;
import com.bistu.sim.xwy.news.domain.NewsInfo;
import com.bistu.sim.xwy.news.domain.NewsUser;
import com.bistu.sim.xwy.news.domain.CollectInfo;
import com.bistu.sim.xwy.news.UserMode.DetailsActivity;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.List;

public class JsonParse {

    public static List<NewsInfo> getNewsInfo(String json){
        Gson gson=new Gson();
        Type listType=new TypeToken<List<NewsInfo>>(){}.getType();
        List<NewsInfo> newsInfos=gson.fromJson(json,listType);
        return newsInfos;
    }
    public static NewsUser getNewsUser(String json){
        Gson gson=new Gson();
        NewsUser newsUser = gson.fromJson(json,NewsUser.class);
        return newsUser;
    }
    public static List<NewsCom>  getAllComs(String json){
        Gson gson=new Gson();
        Type listType=new TypeToken<List<NewsCom>>(){}.getType();
        List<NewsCom> newsCom = gson.fromJson(json,listType);
        return newsCom;
    }
    public static List<BusInfo> getBusInfo(String json){
        Gson gson=new Gson();
        Type listType=new TypeToken<List<BusInfo>>(){}.getType();
        List<BusInfo> busInfos=gson.fromJson(json,listType);
        return busInfos;
    }
    public static BusInfo getDetailsGoods(String json){
        Gson gson = new Gson();
        BusInfo busInfo = gson.fromJson(json,BusInfo.class);
        return busInfo;
    }
    public static BusUser getBusUser(String json){
        Gson gson=new Gson();
        BusUser busUser = gson.fromJson(json, BusUser.class);
        return busUser;
    }
    public static List<BusGood>  getAllGoods(String json){
        Gson gson=new Gson();
        Type listType=new TypeToken<List<BusGood>>(){}.getType();
        List<BusGood> busGood = gson.fromJson(json,listType);
        return busGood;
    }
    public static CollectInfo getCollectInfo(String json){
        Gson gson = new Gson();
        CollectInfo collectInfo = gson.fromJson(json,CollectInfo.class);
        return collectInfo;
    }
    public static NewsInfo getDetailsNews(String json){
        Gson gson = new Gson();
        NewsInfo newsInfo = gson.fromJson(json,NewsInfo.class);
        return newsInfo;
    }
}
